{extend name="public:common_edit"/}
{block name="css"}
    <link href="/public/plugs/switch-button/css/bootstrap-switch.css" rel="stylesheet">
{/block}
{block name="main"}
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i>{$title}</h3>
        </div>
        <div class="panel-body">
            <div class="navbar navbar-default">
                <form action="" id="search-form2" class="navbar-form form-inline" method="get" onsubmit="return false">
                    <!--<label class="control-label" for="input-order-id">房间名</label>-->
                    <!--<div class="input-group">-->
                        <!--<input type="text" name="room_name" value="{$Think.get.room_name}" placeholder="房间名"-->
                               <!--id="input-order-id" class="form-control">-->
                    <!--</div>-->
                    <!--<label class="control-label" for="input-order-id">直播分类</label>-->
                    <!--<div class="input-group">-->
                        <!--{:arr2select('cid',$cate,'全部',input('get.cid'),'cid','cate_name')}-->
                    <!--</div>-->
                    <!--<label class="control-label" for="input-order-id">是否推荐</label>-->
                    <!--<select class="form-control" name="top">-->
                        <!--<option id="top2" value="">全部</option>-->
                        <!--<option id="top1" value="1">是</option>-->
                        <!--<option id="top0" value="0">否</option>-->
                    <!--</select>-->
                    <!--<label class="control-label" for="input-order-id">状态</label>-->
                    <!--<select class="form-control" name="status">-->
                        <!--<option id="status2" value="">全部</option>-->
                        <!--<option id="status1" value="1"> 启用</option>-->
                        <!--<option id="status0" value="0">禁用</option>-->
                    <!--</select>-->
                    <!--<label class="control-label" for="input-order-id">直播状态</label>-->
                    <!--<select class="form-control" name="play">-->
                        <!--<option id="play2" value="">全部</option>-->
                        <!--<option id="play1" value="1">直播中</option>-->
                    <!--</select>-->
                    <!--<button type="submit" onclick="javascript:document.getElementById('search-form2').submit();"-->
                            <!--id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选-->
                    <!--</button>-->
                    <a onclick="add()" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加</a>
                </form>
            </div>
            <div id="ajax_return">
                <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <td>id</td>
                                <td>公告内容</td>
                                <td>排序</td>
                                <td>状态</td>
                                <td>上次修改时间</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody>
                            <!-- 列表循环开始 -->
                            {volist name="rows" id="row"}
                            <tr>
                                <td>{$row.id}</td>
                                <td>{$row.content}</td>
                                <td>{$row.sort}</td>
                                <td>{if condition="$row.status == 1"} 启用 {else /} 禁用 {/if}</td>
                                <td>{:fmt_time($row.update_time)}</td>
                                <td>
                                    <a onclick="edit(this)" data-id="{$row.id}" data-content="{$row.content}" data-sort="{$row.sort}" data-status="{$row.status}" class="btn btn-primary">编辑</a>
                                    {if condition="$row.status == 1"} <span class="btn btn-primary change" data-url="{:url('notice_change',['id'=>$row.id,'type'=>0])}">禁用 </span>
                                    {else /} <span class="btn btn-primary change"  data-url="{:url('notice_change',['id'=>$row.id,'type'=>1])}">启用</span> {/if}
                                    <span class="btn btn-danger check_del" data-url="{:url('notice_del',['id'=>$row['id']])}">删除</span>

                                </td>
                            </tr>
                            {/volist}
                            <!-- 列表循环结束 -->
                            </tbody>
                        </table>
                    </div>
                </form>
            </div>
            <div id='pagerarea'>{$pageHTML}</div>
        </div>
        <div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                        <h4 class="modal-title" id="myModalLabel"> 发布推送</h4></div>
                    <div class="modal-body">
                        <form id="bjy-form" class="form-inline" action="{:url('notice_edit')}" method="post"><input
                                type="hidden" name="id" value="">
                            <table class="table table-striped table-bordered table-hover table-condensed">
                                <tr>
                                    <th>公告内容：</th>
                                    <td><input class="form-control" type="text" name="content"></td>
                                </tr>
                                <tr>
                                    <th width="20%">排序：</th>
                                    <td>
                                        <input class="form-control" placeholder="排序" type="number" name="sort">
                                    </td>
                                </tr>
                                <tr>
                                    <th width="20%">状态：</th>
                                    <td>
                                        <select class="form-control" name="status">
                                            <option value="1">启用</option>
                                            <option value="0">禁用</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <th></th>
                                    <td><input class="btn btn-success submit" type="submit" value="发布"></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{/block}

{block name="js"}
<script src="/public/plugs/switch-button/js/bootstrap-switch.js"></script>
<script>

    function add() {
        $("input[name='content']").val('');
        $("input[name='id']").val('');
        $("input[name='sort']").val(1);
        $("select[name='status']").val(1);
        $('#bjy-add').modal('show');
    }

    function edit(obj) {
        $("input[name='content']").val($(obj).data('content'));
        $("input[name='sort']").val($(obj).data('sort'));
        $("input[name='id']").val($(obj).data('id'));
        $("select[name='status']").val($(obj).data('status'));
        $('#bjy-add').modal('show');
    }


    $(document).ready(function(){
        $(".checkbox").bootstrapSwitch({
            onText:'是',
            offText:'否'
        });
        $('.is_top').on('switchChange.bootstrapSwitch', function (event,state){
            var val = state?1:0;
            var id = $(this).attr('data-id');
            var str = $(this).attr('data-str');
            $.post("{:url('change')}",{id:id,type:val,str:str},function (data) {
                if(data.code!=1){layer.msg('改变状态失败', {icon: 5, time: 2000});}
            });
        });
    });
    $(function () {

    })
</script>



{/block}



